Copyright: Copyright 1993, The Bridge, Inc.


  FormatVB - Format Visual Basic Text

FormatVB.Exe reads Visual Basic text files and creates output suitable for input to a word processor.  Click the browse [>>] button or select a topic for additional help.

Introduction

Writing the Program

Save the Program

Run FormatVB

Run the Word Processor

Copyright 1992
Larry Rebich, The Bridge, Inc.
199 California Drive, Millbrae, CA  94030
800-423-4303 - 415-697-2730
Fax: 415-692-3921

Help last updated: June 10, 1993


FormatVB Introduction

FormatVB reads Visual Basic files and formats them for input to a word processor.  Typically the sequence is:

    1.   Write the Visual Basic program,

    2.   Save the program in text format,

    3.   Run FormatVB,

    4.   Use a Word Processor,

    5.   Print the program listing.

FormatVB was initially written to list VB 1.0 programs saved with VB's code save function.  With the advent of VB 2.0 and its ability to store programs in text format FormatVB was revised to take advantage of the "native" VB text format.

The most significant FormatVB feature is the Table Of Contents.  You will be amazed at how often you refer to the table of contents, especially when researching large files containing common subroutines and functions.


Write the Visual Basic Program

Use Visual Basic to create the program.  Add controls to the form and write code in the normal fashion.  Give each VB form a distinctive name.  For example: MyProg.Frm.  Save subroutines and global variables in a similar manner.


Save the Visual Basic Program

If you are using VB 1.0 save the code using the Save Code function.  VB 1.0 will create a ".Txt" file using the form's name.  For example: if your program's form name is "MyProg.Frm" then the VB 1.0 Save Code function will save it [by default] as "MyProg.Txt".  If you don't know how to use VB Save Code then use VB's help function and search for "Save".

If you are using VB 2.0 or 3.0 force VB to save your program in Text format.  Press F12 or select File, File Save As [Alt F, A] then make sure the Save as Text box is selected.  VB saves the file with the ".frm" extension in ASCII text format.  For example: "MyProg.Frm".

Subroutines, functions and global variables may also be saved in text format using the procedures described above.  FormatVB will format these files.  This is especially useful if you have one large file containing lots of subroutines and functions, for example: MyProg.Bas.  You will be amazed at the number of times you refer to the FormatVB created Table of Contents.


FormatVB - Operation

FormatVB reads Visual Basic text files and formats them for input to a Word Processor.  FormatVB creates a table of contents for each subroutine or function and numbers each line of the document.  Click this hot button "Sample" to display sample output.

FormatVB was written using Visual Basic 2.0.

FormatVB accepts input from any ASCII text file.  FormatVB first scans the entire file to determine the length of the longest line.  It then stores the records in a Random file.  During this process it examines each record to determine if it is a Subroutine or Function heading.  If so it is stored in a work file.

After all records are read, the subroutine/function records are sorted.  They are sorted by group, that is, subroutines which apply to controls are sorted first, other subroutines next and functions last.  A "control" subroutine contains an underline character [ _ ], for example: Form_Load.

The table of contents is build and written to the ".wrk" output file.  After which program code [sorted by subroutine name sequence] is written.

Temporary files are deleted, the ".wrk" file is closed, a "done" beep is issued and FormatVB waits for another file to be selected for processing.

When first started, FormatVB prompts for the name of the file to be processed.  FormatVB uses the Common Dialog routines supplied with the Professional Version of VB [CMDialog.vbx] to prompt for the name of the file to be processed.

FormatVB displays records as they are being read and written.

FormatVB stores a default directory in the FormatVB.Ini file.  Use Option, Set Default Path to store a path name.

The ".wrk" file is used as input to a word processor.  For example: if the FormatVB input file was "MyProg.Frm" the output file is "MyProg.Wrk", the name of the file to be loaded into the word processor.


Word Processor Operation

Any word processing program may be used to print the file produced by FormatVB.  The author uses Word 5.0 and Word for Windows 2.0.  Typical processing steps:

1.	Load the file.  Load the file created by FormatVB.  FormatVB changes the extension to .Wrk.  If the VB program's name is MyProg.Frm then load MyProg.Wrk.

2.	Apply a style.  Pick a font and format style.  You may wish to create a style sheet or template.  You will probably want to use a fixed space font [Letter Gothic, Courier, etc.] for the program code.

3.	Add a heading/footing.  Add a heading or footing.  Typically the heading will contain the name of the program, a brief description and the date.  The footing will probably contain a page number.

4.	Manually paginate the document.  You may wish to manually paginate the document so that page breaks occur at the beginning of subroutines and functions.

5.	Print the document.  Print the document using the Word Processor's standard print routines.

6.	Optionally save the document.  You may wish to save the document, but it's not really necessary.  You will most likely rerun FormatVB before reprinting the program listing.

###


Fonts

Most Word Processors allow you to select fonts.

You will probably want to use a fixed spaced font rather than a proportional spaced font for the main body of your program listing.  Line numbers, code indentations and comments will "line up" properly when printed with a fixed spaced font.  Some popular fixed space fonts include:

Courier, Letter Gothic, Line Printer, Terminal, and Prestige.

The author prefers Letter Gothic.

You may wish to select a proportional spaced font for headings and footings.  The author uses Souvenir, a Bit Stream font.


FormatVB Sample

Controls	Sub MenuHelpAbout_Click	233
Sub MenuQuit_Click	250
Subroutines	Sub FormatVBHelp	345
Sub SetColors	704
'--------------------------------------------------------------------------------------------------------------'
 233 Sub MenuHelpAbout_Click ()
 234     Dim Msg As String, Nl As String * 2
 235     Nl = Chr$(13) + Chr$(10)
 236     Msg = "FormatVB - Format Visual Basic Text" + Nl
 237     Msg = Msg + "Version: " + Version + " " + VersionDate + Nl + Nl
 238     Msg = Msg + "         Copyright " + Format$(Now, "yyyy") + Nl + Nl
 239     Msg = Msg + "         The Bridge, Inc." + Nl
 240     Msg = Msg + "         415-697-2730"
 241     MsgBox Msg, MB_IconQuestion, "About FormatVB"
 242 End Sub
'--------------------------------------------------------------------------------------------------------------'
 704 Sub SetColors ()
 705     BackColor = Application_Workspace   'some color is nice
 706     ForeColor = Window_Text
 707 End Sub
'--------------------------------------------------------------------------------------------------------------'
 794 lines in file n:\formatvb.wrk
 240 characters in longest line
 111 first longest line